package com.mew.common.rest.user;

import com.mew.common.entity.user.User;
import com.zebra.common.ByteBufUtils;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.ToString;

/**
 * @author dylin
 * @create 2021/4/2
 */
@Data
@ToString
public class SimpleUserBO {
    private Long uid;
    private String gid;//名称
    private Integer vipLevel;//vip等级
    private Integer headPath;//头像
    private String nickname;//名称
    private Long goldNumber;//筹码
    private int res = -1;//预留  自定义

    public void write(ByteBuf b) {
        ByteBufUtils.writeLong(b,uid);
        ByteBufUtils.writeString(b,gid);
        ByteBufUtils.writeInt(b,vipLevel);
        ByteBufUtils.writeInt(b,headPath);
        ByteBufUtils.writeString(b,nickname);
        ByteBufUtils.writeLong(b,goldNumber);
        ByteBufUtils.writeInt(b,res);
    }

    public void fromUser(User user,long goldNumber,int vipLevel){
        this.uid = user.getId();
        this.gid = user.getGid();
        this.vipLevel = vipLevel;
        this.headPath = user.getHeadPath();
        this.nickname = user.getNickname();
        this.goldNumber = goldNumber;
    }
}
